/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserInterface.java
 *
 * Created on 10/05/2009, 11:05:06 PM
 */

package UI;

import MapOrganising.ListMaker;
import server.ServerOps;

/**
 *
 * @author Lewis
 */
public class UserInterface extends javax.swing.JFrame {
    
    ServerOps newServer = new ServerOps();

    /** Creates new form UserInterface */
    public UserInterface() {
        initComponents();

        textArea.append( "Mindmap Administration Page" );
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        textPane = new javax.swing.JPanel();
        scrollPane = new javax.swing.JScrollPane();
        textArea = new javax.swing.JTextArea();
        buttonPane = new javax.swing.JPanel();
        StartupButton = new javax.swing.JButton();
        DisplayMasterListButton = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        ShutdownButton = new javax.swing.JButton();
        ExitButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        textArea.setColumns(20);
        textArea.setEditable(false);
        textArea.setRows(5);
        scrollPane.setViewportView(textArea);

        javax.swing.GroupLayout textPaneLayout = new javax.swing.GroupLayout(textPane);
        textPane.setLayout(textPaneLayout);
        textPaneLayout.setHorizontalGroup(
            textPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );
        textPaneLayout.setVerticalGroup(
            textPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
        );

        StartupButton.setText("Startup");
        StartupButton.setToolTipText("Allow server to listen/send/receive data to/from clients.");
        StartupButton.setActionCommand("StartupAction");
        StartupButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartupButtonActionPerformed(evt);
            }
        });

        DisplayMasterListButton.setText("Display Master List");
        DisplayMasterListButton.setActionCommand("DisplayMasterAction");
        DisplayMasterListButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DisplayMasterListButtonActionPerformed(evt);
            }
        });

        jButton3.setText("jButton3");

        ShutdownButton.setText("Shutdown");
        ShutdownButton.setToolTipText("Stop server listening/sending/receiving to/from clients.");
        ShutdownButton.setActionCommand("ShutdownAction");

        ExitButton.setText("Exit");
        ExitButton.setToolTipText("Exit from the server program");
        ExitButton.setActionCommand("ExitAction");
        ExitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExitButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout buttonPaneLayout = new javax.swing.GroupLayout(buttonPane);
        buttonPane.setLayout(buttonPaneLayout);
        buttonPaneLayout.setHorizontalGroup(
            buttonPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPaneLayout.createSequentialGroup()
                .addComponent(StartupButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(DisplayMasterListButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 144, Short.MAX_VALUE)
                .addComponent(ShutdownButton))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, buttonPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ExitButton))
        );
        buttonPaneLayout.setVerticalGroup(
            buttonPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPaneLayout.createSequentialGroup()
                .addGroup(buttonPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(StartupButton)
                    .addComponent(jButton3)
                    .addComponent(ShutdownButton)
                    .addComponent(DisplayMasterListButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                .addComponent(ExitButton))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(buttonPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addComponent(buttonPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void StartupButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartupButtonActionPerformed
        textArea.append( "\n" + newServer.startServer() );
    }//GEN-LAST:event_StartupButtonActionPerformed

    private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitButtonActionPerformed
        System.exit(0);
    }//GEN-LAST:event_ExitButtonActionPerformed

    private void DisplayMasterListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DisplayMasterListButtonActionPerformed
        textArea.append( "\n" + ListMaker.getMasterList() );
}//GEN-LAST:event_DisplayMasterListButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new UserInterface().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton DisplayMasterListButton;
    private javax.swing.JButton ExitButton;
    private javax.swing.JButton ShutdownButton;
    private javax.swing.JButton StartupButton;
    private javax.swing.JPanel buttonPane;
    private javax.swing.JButton jButton3;
    private javax.swing.JScrollPane scrollPane;
    private javax.swing.JTextArea textArea;
    private javax.swing.JPanel textPane;
    // End of variables declaration//GEN-END:variables

}
